package com.tomorrow.analyze;

import java.io.IOException;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.json.JSONException;
import org.json.JSONObject;

import com.tomorrow.weather.entity.Weather;
import com.tomorrow.weather.entity.WeatherInfo;
import com.tomorrow.weather.mInterface.DataAnalyze;

/**
 * 
 * @title
 * @description
 * @author Mike
 * @company www.tomorrow.com
 * @version 1.0
 * @created 2012-10-21
 * 
 */
public class WeatherAnalyze implements DataAnalyze
{
	Weather weather;

	@Override
	public Object getWeatherObject(String strData)
	{
		ObjectMapper mapper = new ObjectMapper();
		try
		{

			// JSONObject jsonObject = new JSONObject(strData);
			// JSONObject weatherinfo = jsonObject.getJSONObject("weatherinfo");

			WeatherInfo weatherInfo = mapper.readValue(strData,
					WeatherInfo.class);
			weather = weatherInfo.getWeatherinfo();
		}

		catch (JsonParseException e)
		{
			e.printStackTrace();
		}
		catch (JsonMappingException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		return weather;
	}

}
